package main

import (
	"fmt"
	"strings"
)

func repeatedStringMatch(a string, b string) int {
	aa := [26]int{}
	for _, v := range a {
		aa[v-'a']++
	}

	for _, v := range b {
		if aa[v-'a'] == 0 {
			return -1
		}
	}

	var repeat = 0
	var repeatStr = ""
	for len(repeatStr) < len(b)*2 || repeat < 3 {
		repeat++
		repeatStr += a
		if strings.Contains(repeatStr, b) {
			return repeat
		}
	}
	return -1
}

func main() {
	fmt.Println(repeatedStringMatch("abcd", "cdabcdab"))
	fmt.Println(repeatedStringMatch("a", "aa"))
	fmt.Println(repeatedStringMatch("abc", "xyz"))
	fmt.Println(repeatedStringMatch("aaaaaaaaaaaaaaaaab", "ba"))
}
